import argparse
import os
import uvicorn


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--env", choices=[
        "production","prod","test","testing","ci","staging","stage","dev","development","local"
    ])
    parser.add_argument("--dotenv")
    parser.add_argument("--host", default="0.0.0.0")
    parser.add_argument("--port", type=int, default=8000)
    parser.add_argument("--reload", action="store_true")
    parser.add_argument("--log-level", choices=["debug","info","warning","error","critical"], default="info")
    args = parser.parse_args()
    if args.dotenv:
        os.environ["DOTENV_FILE"] = args.dotenv
    elif args.env:
        os.environ["FAMES_ENV"] = args.env
    uvicorn.run("app.main:app", host=args.host, port=args.port, reload=bool(args.reload), log_level=args.log_level)


if __name__ == "__main__":
    main()
